<?php
/**
 * @author jonathan <jo.link.noir@gmail.com>
 * @version 1.0: jo_link_noir
 * @date 18-06-2010
 */
class U1_Move
{
	/**
	 * @param string $order : seul le 1er caractère est important
	 * @param int $target
	 * @param SW_Removable $removable = null
	 * @param int $timeEnd = null
	 * @return U1_Move_Transport|U1_Move_Attack|U1_Move_Spy|U1_Move_Base|U1_Move_Colonize
	 * @exception InvalidArgumentException : Invalid order
	 */
	static public function getMoving($order, $target, SW_Removable $removable = null, $timeEnd = null)
	{
		$order = $order[0];
		//attack
		if ('a' === $order)
			return new U1_Move_Attack($target, $timeEnd);

		//transport
		if ('t' === $order)
			return new U1_Move_Transport($target, $removable, $timeEnd);

		//spy
		if ('s' === $order)
			return new U1_Move_Spy($target, $timeEnd);

		//base
		if ('b' === $order)
			return new U1_Move_Base($target, $removable, $timeEnd);

		//colonize
		if ('c' === $order)
			return new U1_Move_Colonize($target, $removable, $timeEnd);

		throw new InvalidArgumentException('Invalid order');
	}
}